home *** CD-ROM | disk | FTP | other *** search
-
- var globalSelect;
- var oldel
- var oldcss
- var q = 0;
-
- function writeSelectBox(matrix, id, size, onchange, css, overCss,borderCss,doborder,cupborder,steps,msec) {
- var d = window.document;
-
- var ie4 = (document.all != null);
-
- if (ie4) {
-
- var s = createIEString(matrix, id, size, onchange, css,overCss,doborder,cupborder,steps,msec);
- document.write(s);
- initSelectBoxes(id,overCss,borderCss);
-
- }
-
-
-
- else {
- document.write(createXString(matrix, id, size, onchange, css));
- initSelectBoxes(id,overCss);
- }
-
-
- }
-
- function createIEString(matrix, id, size, onchange, css, overCss,doborder,cupborder,steps,msec) {
- var str = "";
- var str1="";
-
- html1 = matrix[0].html;
- value1 = matrix[0].value;
- css1 = matrix[0].css;
- selected1 = matrix[0].selected;
-
-
- str1 += '<div class="'+id+'option"';
- if (value1 != null)
- str1+= ' value="' + value1 + '"';
- if (css1 != null)
- str1+= ' style="' + css1 + '"';
- if (selected1 != null)
- str1+= ' selected';
- str1 += '>\n';
-
-
- str1 += html1;
-
- str1 += '</div>\n';
-
-
- str += '<span class="'+id+'select"';
-
- if (size == null)
- size = 1;
- str += ' size="' + size + '"';
- if (id != null)
- str += ' id="' + id + '"';
- if (onchange != null)
- str += ' onchange="' + onchange + '"';
- if (css != null)
- str += ' style="' + css + '"';
- str += '>\n';
-
- str += '<table class="'+id+'selectTable" cellspacing="0" cellpadding="0"\n';
- str += ' onclick="toggleDropDown(this.parentElement,\''+steps+'\',\''+msec+'\')">\n';
- str += '<tr>\n';
- str += '<td class="'+id+'selected">'+str1+'</td>\n';
- str += '<td align="CENTER" valign="MIDDLE" class="'+id+'button"\n';
- str += ' onmousedown="this.style.border=\''+doborder+'\'"\n';
- str += ' onmouseup="this.style.border=\''+cupborder+'\'">\n';
- str += '<span style="position: relative; left: 0; top: -2; width: 100%;">6</span></td>\n';
- str += '</tr>\n';
- str += '</table>\n';
-
-
- str += '<div class="'+id+'dropDown" onclick="optionClick(\''+id+'\', \''+overCss+'\',\''+steps+'\',\''+msec+'\')" onmouseover="optionOver(\''+id+'\', \''+overCss+'\')" onmouseout="optionOut(\''+id+'\', \''+overCss+'\')">\n';
-
- for (var i=0; i<matrix.length; i++) {
- html = matrix[i].html;
- value = matrix[i].value;
- css = matrix[i].css;
- selected = matrix[i].selected;
-
-
- str += '<div class="'+id+'option"';
- if (value != null)
- str += ' value="' + value + '"';
- if (css != null)
- str += ' style="' + css + '"';
- if (selected != null)
- str += ' selected';
- str += '>\n';
- str += html;
- str += '</div>\n';
- }
-
-
- str += '</div>\n';
- str += '</span>\n';
-
-
-
-
- return str;
- }
-
- function createXString(matrix, id, size, onchange, css) {
-
- var str = '<form>\n';
- str += '<select';
- if (size == null)
- size = 1;
- str += ' size="' + size + '"';
- if (id != null)
- str += ' id="' + id + '"';
- if (onchange != null)
- str += ' onchange="' + onchange + '"';
- str += '>\n';
-
- for (var i=0; i<matrix.length; i++) {
- html = matrix[i].html;
- value = matrix[i].value;
- css = matrix[i].css;
- selected = matrix[i].selected;
- str += '\n<option';
- if (value != null)
- str += ' value="' + value + '"';
- if (selected != null)
- str += ' selected';
- str += '>';
- str += stripTags(html);
- str += '</option>\n';
- }
- str += '\n</select>\n';
- str += '</form>\n';
-
- return str;
- }
-
- function stripTags(str) {
- var s = 0;
- var e = -1;
- var r = "";
-
- s = str.indexOf("<",e);
-
- do {
- r += str.substring(e + 1,s);
- e = str.indexOf(">",s);
- s = str.indexOf("<",e);
- }
- while ((s != -1) && (e != -1))
-
- r += str.substring(e + 1,str.length);
-
- return r;
- }
-
- function Option(html, value, css, selected) {
- this.html = html;
- this.value = value;
- this.css = css;
- this.selected = selected;
- }
-
- function initSelectBox(el,id,overCss,borderCss) {
-
-
- var size = el.getAttribute("size");
-
- el.options = el.children[1].children;
- el.selectedIndex = findSelected(el);
- el.remove = new Function("i", "int_remove(this,i)");
- el.item = new Function("i", "return this.options[i]");
- el.add = new Function("e", "i", "int_add(this, e, i,id)");
- el.options[el.selectedIndex].selected = true;
-
- dropdown = el.children[1];
-
- if (size != null) {
- if (size > 1) {
- el.size = size;
- dropdown.style.zIndex = 0;
- initSized(el,borderCss);
- }
- else {
- el.size = 1;
- dropdown.style.zIndex = 99;
- if (dropdown.offsetHeight > 200) {
- dropdown.style.height = "200";
- dropdown.style.overflow = "auto";
- }
- }
- }
-
-
- }
-
- function int_remove(el,i) {
- if (el.options[i] != null)
- el.options[i].outerHTML = "";
- }
-
- function int_add(el, e, i) {
- var html = "<div class='"+id+"option' noWrap";
- if (e.value != null)
- html += " value='" + e.value + "'";
- if (e.style.cssText != null)
- html += " style='" + e.style.cssText + "'";
- html += ">";
- if (e.text != null)
- html += e.text;
- html += "</div>"
-
- if ((i == null) || (i >= el.options.length))
- i = el.options.length-1;
-
- el.options[i].insertAdjacentHTML("AfterEnd", html);
- }
-
- function initSized(el,borderCss) {
- var h = 0;
- el.children[0].style.display = "none";
-
- dropdown = el.children[1];
- dropdown.style.visibility = "visible";
-
- if (dropdown.children.length > el.size) {
- dropdown.style.overflow = "auto";
- for (var i=0; i<el.size; i++) {
- h += dropdown.children[i].offsetHeight;
- }
-
- if (dropdown.style.borderWidth != null) {
- dropdown.style.pixelHeight = h + 4;
- }
-
- else
- dropdown.style.height = h;
-
- }
-
- dropdown.style.border = borderCss;
-
-
- el.style.height = dropdown.style.pixelHeight;
- }
-
- function copySelected(el) {
- var selectedIndex = findSelected(el);
-
- selectedCell = el.children[0].rows[0].cells[0];
- selectedDiv = el.children[1].children[selectedIndex];
-
- selectedCell.innerHTML = selectedDiv.outerHTML;
- }
-
- function findSelected(el) {
- var selected = null;
-
- ec = el.children[1].children;
- var ecl = ec.length;
-
- for (var i=0; i<ecl; i++) {
- if (ec[i].getAttribute("selected") != null) {
- if (selected == null) {
- selected = i;
- }
- else
- ec[i].removeAttribute("selected");
- }
- }
- if (selected == null)
- selected = 0;
-
- return selected;
- }
-
- function toggleDropDown(el,steps,msec) {
- if(oldel!=null)
- {
- if (oldel==el)
- {
- if (el.size == 1) {
- dropDown = el.children[1];
-
- if (dropDown.style.visibility == "")
- dropDown.style.visibility = "hidden";
-
- if (dropDown.style.visibility == "hidden")
- showDropDown(dropDown,steps,msec);
- else
- hideDropDown(dropDown,steps,msec);
- }
- }
- else
- {
-
- if (oldel.size == 1) {
- alert(oldel.id)
- dropDown = oldel.children[1];
-
- if (dropDown.style.visibility == "")
- dropDown.style.visibility = "hidden";
-
- if (dropDown.style.visibility == "hidden")
- showDropDown(dropDown,steps,msec);
- else
- hideDropDown(dropDown,steps,msec);
-
- }
- if (el.size == 1) {
- dropDown = el.children[1];
-
- if (dropDown.style.visibility == "")
- dropDown.style.visibility = "hidden";
-
- if (dropDown.style.visibility == "hidden")
- showDropDown(dropDown,steps,msec);
- else
- hideDropDown(dropDown,steps,msec);
-
- }
-
- oldel=el
- }
- }
- else
- {
- if (el.size == 1) {
- dropDown = el.children[1];
-
- if (dropDown.style.visibility == "")
- dropDown.style.visibility = "hidden";
-
- if (dropDown.style.visibility == "hidden")
- showDropDown(dropDown,steps,msec);
- else
- hideDropDown(dropDown,steps,msec);
-
- }
- oldel=el
-
- }
- }
-
- function optionClick(id,overCss,steps,msec) {
- tagid = id;
-
- tagcss=id+"option"
-
- el = getReal(window.event.srcElement, "className", tagcss);
-
- if (el.className == tagcss) {
- dropdown = el.parentElement;
- selectBox = dropdown.parentElement;
-
- oldSelected = dropdown.children[findSelected(selectBox)]
- if(oldSelected != el) {
- oldSelected.removeAttribute("selected");
- el.setAttribute("selected", 1);
- selectBox.selectedIndex = findSelected(selectBox);
- }
-
- if (selectBox.onchange != null) {
- if (selectBox.id != "") {
- eval(selectBox.onchange.replace(/this/g, selectBox.id));
- }
- else {
- globalSelect = selectBox;
- eval(selectBox.onchange.replace(/this/g, "globalSelect"));
- }
- }
-
- var selectedIndex = findSelected(selectBox);
- selectedCell = selectBox.children[0].rows[0].cells[0];
- selectedDiv = selectBox.children[1].children[selectedIndex];
-
-
- selectedCell.innerHTML = selectedDiv.innerText;
- selectedCell.style.cssText=oldcss;
- toggleDropDown(selectBox,steps,msec);
- highlightSelected(selectBox, true,overCss);
- }
- }
-
- function optionOver(id,overCss) {
- tagcss=id+"option"
-
- var toEl = getReal(window.event.toElement, "className", tagcss);
- var fromEl = getReal(window.event.fromElement, "className", tagcss);
- if (toEl == fromEl) return;
- var el = toEl;
-
- if (el.className == tagcss) {
- oldcss= el.children[0].children[0].style.cssText;
- if (el.backupCss == null)
- {
- el.backupCss = el.children[0].children[0].style.cssText;
- }
- highlightSelected(el.parentElement.parentElement, false,overCss);
- el.style.cssText = el.backupCss + "; " + overCss;
- el.children[0].children[0].style.cssText=el.style.cssText
- this.highlighted = true;
- }
- }
-
- function optionOut(id,overCss) {
- tagcss=id+"option"
- var toEl = getReal(window.event.toElement, "className", tagcss);
- var fromEl = getReal(window.event.fromElement, "className", tagcss);
-
- if (fromEl == fromEl.parentElement.children[findSelected(fromEl.parentElement.parentElement)]) {
- if (toEl == null)
- return;
- if (toEl.className != tagcss)
- return;
- }
-
- if (toEl != null) {
- if (toEl.className != tagcss) {
- if (fromEl.className == tagcss)
- highlightSelected(fromEl.parentElement.parentElement, true,overCss);
- }
- }
-
- if (toEl == fromEl) return;
- var el = fromEl;
-
- if (el.className == tagcss) {
- if (el.backupCss != null)
- el.style.cssText = el.backupCss;
- el.children[0].children[0].style.cssText=el.style.cssText
- }
-
- }
-
- function highlightSelected(el,add,overCss) {
- var selectedIndex = findSelected(el);
-
- selected = el.children[1].children[selectedIndex];
-
-
- if (add) {
- if (selected.backupCss == null)
- selected.backupCss = selected.children[0].children[0].style.cssText;
- selected.style.cssText = selected.backupCss + "; " + overCss;
- selected.children[0].children[0].style.cssText=selected.style.cssText
- }
- else if (!add) {
- if (selected.backupCss != null)
- selected.style.cssText = selected.backupCss;
- selected.children[0].children[0].style.cssText=selected.style.cssText
- }
- }
-
-
-
- function hideDropDown(el,steps,msec) {
- if (typeof(fade) == "function")
- fade(el, false,steps,msec);
- else
- el.style.visibility = "hidden";
- }
-
- function showDropDown(el,steps,msec) {
- if (typeof(fade) == "function")
- fade(el, true,steps,msec);
- else if (typeof(swipe) == "function")
- swipe(el, 2);
- else
- el.style.visibility = "visible";
- }
-
- function initSelectBoxes(id,overCss,borderCss) {
- var spans = document.all.tags("SPAN");
- var selects = new Array();
- var index = 0;
- tagcss=id+"select";
- for (var i=0; i<spans.length; i++) {
- if (spans[i].className == tagcss)
- selects[index++] = spans[i];
- }
-
- for (var j=0; j<selects.length; j++) {
- initSelectBox(selects[j],id,overCss,borderCss);
- }
- }
-
- function getReal(el, type, value) {
- temp = el;
- if (value!="select")
- {
- while ((temp != null) && (temp.tagName != "BODY")) {
- if (eval("temp." + type) == value) {
- el = temp;
- return el;
- }
- temp = temp.parentElement;
- }
- }
- else
- {
- if((temp != null) && (temp.tagName != "BODY") && (temp.id!=""))
- {
- value=temp.id+value
- }
-
- while ((temp != null) && (temp.tagName != "BODY")) {
- if (eval("temp." + type) == value) {
- alert(temp.id)
- el = temp;
-
- return el;
- }
- temp = temp.parentElement;
-
- }
- }
- return el;
- }
-
-
- function hideShownDropDowns() {
-
- var el = getReal(window.event.srcElement, "className", "select");
- var spans = document.all.tags("SPAN");
- var selects = new Array();
- var index = 0;
-
- strTemp="fadesteps"
- strMesc="fademsec"
-
- for (var i=0; i<spans.length; i++) {
- if ((spans[i].className.indexOf("select")) && (spans[i] != el)) {
- dropdown = spans[i].children[1];
- if ((spans[i].size == 1) && (dropdown.style.visibility == "visible"))
- selects[index++] = dropdown;
- }
- }
-
- for (var j=0; j<selects.length; j++) {
- idtemp=selects[j].parentElement.id
-
-
-
- hideDropDown(selects[j],eval(idtemp+strTemp),eval(idtemp+strMesc));
- }
-
-
- if (oldel!=null)
- {
- if (oldel.size == 1) {
- dropDown = oldel.children[1];
- idold=oldel.id
- if (dropDown.style.visibility == "")
- dropDown.style.visibility = "hidden";
-
- if (dropDown.style.visibility == "hidden")
- showDropDown(dropDown,eval(idold+strTemp),eval(idold+strMesc));
- else
- hideDropDown(dropDown,eval(idold+strTemp),eval(idold+strMesc));
-
- }
- }
- oldel=null
-
- }
-
- if (document.all != null) {
- document.onclick = hideShownDropDowns;
- }